package china.song314.testcode;

import china.song314.bean.UserInfo;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class TestJSON {

	int song = 11;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		UserInfo user = new UserInfo("imei", "song", "1234", -1, 0);
		JSONObject jsonObject = JSONObject.fromObject(user);
		System.out.println(jsonObject.toString());
		JSONArray jsonArray = JSONArray.fromObject(user.getShareSite());
		System.out.println(jsonArray.toString());
//		System.out.println("isMemberField = " + isMemberField("K"));
//		System.out.println("isMemberField = " + isMemberField("k"));
//		System.out.println("isMemberField = " + isMemberField("456"));
		
		print(user.toJSONString());
		print(user.toJSONString(UserInfo.TITILE_SINA));
		print(user.toJSONString(UserInfo.TITILE_FACEBOOK));
		print(user.toJSONString(UserInfo.TITILE_TWITTER));
//		print(user.toJSONString(""));
	}
	
	private static boolean isMemberField(String name) {
		String head = name.substring(0, 1);
		return head.equals(head.toLowerCase());
	}

	
	private static void print(String msg) {
		System.out.println(msg);
	}
}
